<!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="stylesheet" type="text/css" href="../../css/base.css" />
    <link id="easyuiTheme" rel="stylesheet" type="text/css" href="../../easy-ui/themes/default/easyui.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="../../easy-ui/themes/icon.css" />
   	<script type="text/javascript" src="../../easy-ui/jquery.min.js"></script>
    <script type="text/javascript" src="../../easy-ui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../js/base.js" ></script>
   
   </head>
   
   
	<body class="easyui-layout" style="overflow:hidden"  fit="true"   scroll="no">
	
	
	<ul id="grid" class="easyui-grid" style="width:100%;" data-options="border:true,
													region:'center',
													fit:true,
													fitColumns:true,
													rownumbers:true,
													singleSelect:false,
													toolbar:'#tb'">
		
	</ul>

	<div id="tb" style="padding:0px;height:auto;overflow:auto;">
	<div style="height:3px;"></div>
			
				<form id="baseForm" name="baseForm" action="" method="post" target="hiddenFrame" style="margin:0px;"> 
					
					<input  name="ids"  id="ids" type="hidden" ></input>
					<input  name="status"  id="status" type="hidden" ></input>
					<input  name="type"  id="type" type="hidden" value="B"></input>
					
						<span style="width:3px;">&nbsp;</span>			
						
						
						
						<span id="sys_res_086167638C4A4AB98161D8466ADEAE61" >
							<a href='javascript:void(-1);' onclick="addRecord();" class="easyui-linkbutton" iconCls="icon-add" plain="true" >
							新增
							</a>
						</span> 
						<span id="sys_res_1168" >
							<a href='javascript:void(-1);' onclick="updateRecord();" class="easyui-linkbutton" iconCls="icon-edit" plain="true" >
							修改
							</a>
						</span>
						<!-- <span id="sys_res_1169" >
							<a href='javascript:void(-1);' onclick="deleteRecord();" class="easyui-linkbutton" iconCls="icon-remove" plain="true"  >
							删除
							</a>
					    </span>	
					  
						<span id="sys_res_06EE02AA4B3C42C389FE231B16C06F72" style="display:none">
							<a href='javascript:void(-1);' onclick="optRecord();" class="easyui-linkbutton" iconCls="icon-edit" plain="true" >
							审核
							</a>
						</span>
						<span id="sys_res_0AA43BDF17754336A4E8D66B23C90636" style="display:none">
							<a href='javascript:void(-1);' onclick="blackRecord();" class="easyui-linkbutton" iconCls="icon-edit" plain="true" >
							移入黑名单
							</a>
						</span>
						<span id="sys_res_94CFF37661D94E58B9D4A2C1AE316F49" style="display:none">
							<a href='javascript:void(-1);' onclick="okRecord();" class="easyui-linkbutton" iconCls="icon-edit" plain="true" >
							解除黑名单
							</a>
						</span>
						<span id="sys_res_33457BBE80804B8E9ECA4239EC0B6538" style="display:none">
							<a href='javascript:void(-1);' onclick="shopUserRecord();" class="easyui-linkbutton" iconCls="icon-edit" plain="true" >
							商家用户
							</a>
						</span>-->
						 <br>
						 <span id="search_span_id" style="margin-left:20px;color: #484848;" >
						注册日期：<input  name="minRegTime" id="minRegTime" style="width:150px;" class="easyui-datebox" data-options="prompt:'请选择日期',formatter:myformatterDateYMD,parser:myparserDateYMD,required:true,novalidate:true" ></input> ~
							  <input  name="maxRegTime" id="maxRegTime" style="width:150px;;" class="easyui-datebox" data-options="prompt:'请选择日期',formatter:myformatterDateYMD,parser:myparserDateYMD,required:true,novalidate:true"></input>
							  状态：<input class="easyui-combobox" id="searchStatus_combobox" data-options="valueField:'id',textField:'text',editable:false" style="width:80px"/>
							<input class="easyui-textbox" id="name" name="name" data-options="buttonText:'搜索',buttonIcon:'icon-search',prompt:'请输入店名',onClickButton:doSearch"
							 style="width:256px;"/>
						 </span>
				</form> 
				
	<div style="height:3px;"></div>	
	</div>
			
	
	


	


<script type="text/javascript">
	var gridId="grid";
	var frameId="create_tabs_iframe_"+getQueryString("frameId");
	var add_window;
	var update_window;
	var view_window;
	var search_window;
	var selections;
	var gridDataUrl='../../zcshop/grid.do?responseFunction=grid';
	
	window.onload = function(){
		search_window
		=parent.createModalWindowWithUrl('460','433','search_window','查询商户','../pages/shop/form_search.html?1=1','searchWindowCallback','');
		initPage();
	} 
	
	function initPage(){
		parent.showProgressing();
		sendRequestAjax(gridDataUrl,grid);
		 $('#searchStatus_combobox').combobox({
			 data: [{id:'',text:'--请选择--'},{id:'1',text:'待审核'},{id:'2',text:'审核不通过'},{id:'3',text:'正常'},{id:'4',text:'暂时闭店'},{id:'5',text:'永久闭店'},{id:'6',text:'黑名单'}],
		  		value:"",
		  		onSelect: function(record){
			  			document.getElementById("status").value=record.id;
			  			//document.getElementById("searchSexShow").value=record.text;
				}
			});
	}
	
	
	
	
	function addRecord(){
		parent.parent.addTab("new_shop","新增商户",'../pages/shop/form_add.html?1=1&callbackFunction=reloadPageData&targetFrame='+frameId,"zcshop");
	}
	
	
	
	function updateRecord(){
		
	 	selections = $('#grid').datagrid('getSelections');
	 	
	 	if(!selectOnlyOne(selections)){
	 		return false;
	 	}
	 	
		parent.parent.addTab("edit_shop","修改商户",'../pages/shop/form_update.html?1=1&callbackFunction=reloadPageData&targetFrame='+frameId,"shopE");
	 	
	}
	
	function optRecord(){
		
	 	selections = $('#grid').datagrid('getSelections');
	 	if(!selectOnlyOne(selections)){
	 		return false;
	 	}
	 	if(selections[0].status==1){
			parent.parent.addTab("opt_shop","审核商户",'../pages/shop/form_opt.html?1=1&callbackFunction=reloadPageData&targetFrame='+frameId,"shopO");
	 	}else{
	 		parent.$.messager.alert('消息提示','不需审核的记录!','info');
	 		return false;
	 	}
	}
	
	function blackRecord(){
		selections = $('#grid').datagrid('getSelections');
		if(!selectMoreOne(selections)){
	 		return false;
	 	}
	 	
	 	parent.$.messager.confirm("操作提示", "您确定要把选中商户移入黑名单吗?", function(data){
            if(data){
            	var selections = $('#grid').datagrid('getSelections');

				var idParams="";
			 	for(var i=0;i<selections.length;i++){
			 	 	idParams=idParams+""+selections[i].id+",";
				}
				parent.showProgressing(); 
				document.getElementById('ids').value=idParams.substr(0,idParams.length-1)
				gridOperate(gridId,'../../zcshop/blackByIds.do?responseFunction=blackByIds',reloadPageData);
            }else {
               
            }
		});
	} 
	
	function okRecord(){
		selections = $('#grid').datagrid('getSelections');
		if(!selectMoreOne(selections)){
	 		return false;
	 	}
	 	
	 	parent.$.messager.confirm("操作提示", "您确定要把选中商户解除黑名单吗?", function(data){
            if(data){
            	var selections = $('#grid').datagrid('getSelections');

				var idParams="";
			 	for(var i=0;i<selections.length;i++){
			 	 	idParams=idParams+""+selections[i].id+",";
				}
				parent.showProgressing(); 
				document.getElementById('ids').value=idParams.substr(0,idParams.length-1)
				gridOperate(gridId,'../../zcshop/outBlackByIds.do?responseFunction=blackByIds',reloadPageData);
            }else {
               
            }
		});
	} 

	function shopUserRecord(){
		selections = $('#grid').datagrid('getSelections');
	 	
	 	if(!selectOnlyOne(selections)){
	 		return false;
	 	}
	 	
		parent.parent.addTab("point_log_user","商家用户列表",'../pages/shop/userlist.html?1=1&callbackFunction=reloadPageData&targetFrame='+frameId,"shopuser");
	} 
	
	function viewRecord(id){
		
		selections=[{"id":id}];
		
		
		parent.parent.addTab("view_shop","查看商户",'../pages/shop/form_view.html?1=1&callbackFunction=reloadPageData&targetFrame='+frameId,"shopV");
		
	}   
	
	
	function deleteRecord(){
		selections = $('#grid').datagrid('getSelections');
		if(!selectMoreOne(selections)){
	 		return false;
	 	}
	 	
	 	parent.$.messager.confirm("操作提示", "您确定要删除吗?", function(data){
						
            if(data){
            	var selections = $('#grid').datagrid('getSelections');

				var idParams="";
			 	for(var i=0;i<selections.length;i++){
			 	 	idParams=idParams+""+selections[i].id+",";
				}
				parent.showProgressing(); 
				document.getElementById('ids').value=idParams.substr(0,idParams.length-1)
				gridOperate(gridId,'../../zcshop/deleteByIds.do?responseFunction=deleteByIds',reloadPageData);
            }else {
               
            }
		});
	} 
	
	
	function deleteRecordCallback(responseResult){
	
		loadPageDataCallback(responseResult);
		
	}
 	
	function showSearch(){
		
		search_window.openModalWindow();
		
	}

	function searchWindowCallback(json){  
		
		var titleStr="";
		
		titleStr=titleStr+wiriteSearchValueLabel("searchName","商户名称",json.name,json.name);
		titleStr=titleStr+wiriteSearchValueLabel("minRegTime","注册日期",json.minRegTime,json.minRegTime);
		titleStr=titleStr+wiriteSearchValueLabel("maxRegTime","注册日期",json.maxRegTime,json.maxRegTime);
		titleStr=titleStr+wiriteSearchValueLabel("type","类型",json.type,json.type);
		titleStr=titleStr+wiriteSearchValueLabel("status","状态",json.status,json.status);
		
		document.getElementById('accurate_search_id').title=titleStr;
		
		if(titleStr!=""){
			changeSearchIcon(true);
		}else{
			changeSearchIcon(false);
		}
		
		reloadPageData();
	}
	
	var columns=[[
	{"field":"id","formatter":"","width":158,"title":"","align":"center","checkbox":true,"rowStyler":""},
	{"field":"name","formatter":"","width":158,"title":"主店名","align":"center","checkbox":false,"rowStyler":""},
	{"field":"subName","formatter":"","width":158,"title":"分店名","align":"center","checkbox":false,"rowStyler":""},
	{"field":"shortName","formatter":"","width":158,"title":"简称","align":"center","checkbox":false,"rowStyler":""},
	{"field":"type","formatter":function(value,rowData,rowIndex){if(rowData.type==1){return '商场内的商户' } else if(rowData.type==2){return '商场外的商户' } else if(rowData.type==3){return '购物中心或百货' }else if(rowData.type==4){return '商场-百货' }else if(rowData.type==5){return '机构类商家' }},"width":158,"title":"类型","align":"center","checkbox":false,"rowStyler":""},
	{"field":"regTime","formatter":function(value,rowData,rowIndex){ return  switchTime(rowData.regTime,2)},"width":158,"title":"注册时间","align":"center","checkbox":false,"rowStyler":""},
	{"field":"status","formatter":function(value,rowData,rowIndex){if(rowData.status==1){return '申请中' }else if(rowData.status==0){return '待申请' }else if(rowData.status==3){return '正常' }else if(rowData.status==4){return '暂时闭店' }else if(rowData.status==5){return '永久闭店' }else if(rowData.status==6){return '黑名单' }},"width":158,"title":"状态","align":"center","checkbox":false,"rowStyler":""},
	{"field":"updateLastTime","formatter":function(value,rowData,rowIndex){   return  "<a  href='javascript:void(-1);' onclick='viewRecord(\""+rowData.id+"\");'>查看</a>";  },"width":80,"title":"操作","align":"center","checkbox":false,"rowStyler":""}
	]];
	
	
	
	//初始化数据
     function grid(responseResult){  
		
		 valiAuth(responseResult);
		 $('#grid').datagrid({
	         columns:columns, 
	         pagination:true 
	     }); 
 
 	    loadPageDataCallback(responseResult);  
       
     }
	
	
	
	//重新载入数据
	function reloadPageData(){
	
		parent.showProgressing();
		gridOperate('grid',gridDataUrl,loadPageDataCallback);
		
	}
	
	function reloadPageDataSimple(){
	
		gridOperate('grid',gridDataUrl,loadPageDataCallback);
	
	}
	
	
	
	//初始化数据
     function loadPageDataCallback(responseResult){  
		
			   $('#'+gridId).datagrid("loaded");//不需要显示加载状态   
		       $('#'+gridId).datagrid("loadData",responseResult.data);//将数据绑定到DataGrid中
		
		       setPager('grid',
		       responseResult.data.pageNo,
		       responseResult.data.total,
		       responseResult.data.pageCount,
		       responseResult.data.pageStartOffset,
		       responseResult.data.pageSize,
		       gridDataUrl,
		       grid
		       );
		       
       		   parent.closeProgressing(); 
     }
	
	
	
	
	document.onkeydown = function(evt){
   		 
   		 var evt = window.event?window.event:evt;
   	 if (evt.keyCode==13){
    
    		$("#search_span_id").find(".textbox-button").focus();
    		$("#search_span_id").find(".textbox-button").click();
    		$("#search_span_id").find(".textbox-text").focus();
    		
         }
    }
	
	
	
	$(window).resize(function(){
		
		$('#grid').datagrid('resize', {
			width:document.body.clientWidth,
			height:window.innerHeight,
		});
		
	}); 
	
	
	
	
</script>

</body>
</html>